
lst = [10, 28, 33, 66, 77 ,81, 87,  89, 99, 101, 102]
a = 81
# 81在这列表中的索引
# print(lst.index(81))

# for i in range(len(lst)):
#     if a==lst[i]:
#         print(i)

def binary_search(lst, t, l, r):
    if r-l==0:
        return '不存在'
    mid = len(lst[l:r])//2+l
    if lst[mid] == t:
        return mid
    elif lst[mid] > t:
        return binary_search(lst, t, l, mid)
    elif lst[mid]< t:
        return binary_search(lst, t, mid+1, r)
num = binary_search(lst, a, 0, len(lst))

print(num)